package com.hspedu.homework.homework13;

/**
 * @Author Stringzhua
 * @Date 2024/3/3 20:14
 * description:父类Person
 * 将共同属性和方法放到Person类
 */
public class Person {//父类
    //属性
    private String name;
    private char gender;
    private int age;
    //方法

    public Person(String name, char gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //学生和老师都有一个玩的方法
    //学生爱玩足球 老师爱玩象棋
    //分别返回字符串的，xx爱玩足球 xx爱玩象棋(xx 代表的是老师和学生的姓名)
    //把共有的输出内容写到父类
    public String play() {
        return name + "爱玩";
    }

    //打印信息的方法printInfo
    //姓名、年龄、性别-->基本信息在父类实现,返回一个基本信息basicInfo
    public String basicInfo() {
        return "姓名:" + name + "\n年龄:" + age + "\n性别:" + gender;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                '}';
    }
}
